home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Is there a problem using memset on a malloc'd memory in HP-C
- Date: 26 Mar 1996 16:06:29 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4ja0q5INN8a6@keats.ugrad.cs.ubc.ca>
- References: <31a7cc$10b20.32c@NEWS>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <31a7cc$10b20.32c@NEWS>,
- Jonathan Julian <jul395@prb.mhs.compuserve.com> wrote:
- >I have searched your FAQ and found no reference to this problem.
- >
- >I am having trouble doing a malloc on memory that I allocated via
- >malloc. I malloc'd the memory, memset it and immediately look at it
- >and it is garbage. I have changed my mallocs to callocs, but later in
- >my code I realloc. Since realloc does not initialize and I
- >distrusting of memset I have written a loop to initialize my memory.
-
- Unfortunately, without seeing the source code demonstrating your use of
- malloc() and memset(), there is little that can be done in the way of help.
-
- >The structure that I am trying to initialize is an array of pointers
- >to pointers that I would initially like to be NULL. I am on HP
- >a.09.07 using HP-C
-
- Unfortunately, if you expect a block of zero bits to represent null pointers,
- you are making a machine-specific assumption. The null pointer is not required
- by the C standard to have a zero-bit representation, to reflect the reality
- that on some machines the best represetnation for a null pointer is something
- other than a word of zero bits.
-
- If you want to be strictly conforming, you should intitialize each pointer by
- explicit assignment.
- --
-
-